import ip from './config.js'
import qs from 'qs'
import axios from 'axios'

export const getData = (url, obj, type) => new Promise((resolve, reject) => {
	let token = {
		token: sessionStorage.token
	}
	let datas = Object.assign(token, obj)
	let data = qs.stringify(datas)
	let options = {}
	if(type) {
		options = {
		  method: 'get',
		//  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
		  params: datas,
		  url: ip + url,
		};	
	} else {
		options = {
		  method: 'post',
		//  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
		  data: data,
		  url: ip + url,
		};		
	}
	axios(options).then(d => {
		resolve(d.data)
	}).catch(err => {
		reject(err)
	})
})



